// 按需引入方式
// import echarts from "@/views/package/echarts/components/BaseEcharts/utils/echarts";

export function getOptions(requestData) {
  console.log("requestData", requestData);
  const colorList = ["#d19a42", "#66d6fb", "red"];
  const defaultFontColor = "#fff";
  const dataList = [
    {
      name: "发电量",
      yAxisName: "发电量(亿度)",
      data: [386, 11, 13, 11, 12, 12, 9],
      color: colorList[0],
    },

    {
      name: "三峡来水量",
      yAxisName: "来水量(m³)",
      data: [1, -2, 2, 5, 3, 2, 0],
      color: colorList[1],
    },
    {
      name: "三峡上游水位",
      yAxisName: "三峡上游水位(m)",
      data: [1, -22, 2, 5, 3, 2, 0],
      color: colorList[2],
    },
  ];

  const option = {
    tooltip: {
      trigger: "axis",
      backgroundColor: "#283c7e",
      borderColor: "#283c7e",
      textStyle: {
        color: "#fff",
      },
    },
    legend: {
      data: dataList.map((item) => {
        return {
          name: item.name,
          textStyle: { color: item.color },
        };
      }),
    },
    // grid: [
    //   {
    //     top: 70,
    //     bottom: 101,
    //     left: 50,
    //     right: 30,
    //   },
    // ],
    toolbox: {
      show: true,
      feature: {
        dataZoom: {
          yAxisIndex: "none",
        },
        dataView: { readOnly: false },
        magicType: { type: ["line", "bar"] },
        restore: {},
        saveAsImage: {},
      },
    },
    xAxis: {
      type: "category",
      boundaryGap: false,
      data: ["2006", "2009", "2012", "2015", "2018", "2021", "2023"],
      axisLine: {
        show: true,
        lineStyle: {
          color: dataList[1].color,
          width: 2,
        },
      },
      axisLabel: {
        //y轴文字的配置
        textStyle: {
          color: defaultFontColor,
          margin: 15,
        },
      },
      splitLine: {
        show: true,
        lineStyle: {
          color: "#ccc",
          type: "dashed",
          dashOffset: "20",
          opacity: 0.3,
        },
      },
    },

    yAxis: [
      {
        name: dataList[0].yAxisName,
     
        type: "value",
        position: "left",
        offset: "80",
        axisLine: {
          show: true,
          lineStyle: {
            color: dataList[0].color,
            width: 2,
          },
        },
        axisTick: {
          show: true,
        },
        axisLabel: {
          //y轴文字的配置
          textStyle: {
            color: defaultFontColor,
            margin: 15,
          },
        },
        splitLine: {
          show: false,
          lineStyle: {
            color: dataList[0].color,
            opacity: 0.3,
          },
        },
      },
      {
        name: dataList[1].yAxisName,
        type: "value",
        position: "left",
        offset: "0",
        axisTick: {
          show: true,
        },
        alignTicks: true, // 开启该配置项自动对齐刻度
        axisLine: {
          show: true,
          lineStyle: {
            color: dataList[1].color,
            width: 2,
          },
        },
        axisLabel: {
          //y轴文字的配置
          textStyle: {
            color: defaultFontColor,
            margin: 15,
          },
        },
        splitLine: {
          show: true,
          lineStyle: {
            color: "#ccc",
            type: "dashed",
            dashOffset: "20",
            opacity: 0.3,
          },
        },
      },

      {
        name: dataList[2].yAxisName,
        type: "value",
        position: "right",
        // offset: '40',
        axisTick: {
          show: true,
        },
        axisLine: {
          show: true,
          lineStyle: {
            color: dataList[2].color,
            width: 2,
          },
        },
        axisLabel: {
          //y轴文字的配置
          textStyle: {
            color: defaultFontColor,
            margin: 15,
          },
        },
        splitLine: {
          show: false,
          lineStyle: {
            color: dataList[2].color,
            opacity: 0.3,
          },
        },
      },
    ],
    series: [
      {
        name: dataList[0].name,
        type: "line",
        data: dataList[0].data,
        lineStyle: {
          color: dataList[0].color,
        },
        showSymbol: true, //是否默认展示圆点
        symbolSize: 10, //设定实心点的大小
        itemStyle: {
          normal: {
            color: dataList[0].color, //改变折线点的颜色
          },
        },
        markPoint: {
          data: [{ type: "max", name: "Max" }],
        },
        yAxisIndex: 0,
      },
      {
        name: dataList[1].name,
        type: "line",
        data: dataList[1].data,
        lineStyle: {
          color: dataList[1].color,
        },
        showSymbol: true, //是否默认展示圆点
        symbolSize: 10, //设定实心点的大小
        itemStyle: {
          normal: {
            color: dataList[1].color, //改变折线点的颜色
          },
        },
        markPoint: {
          data: [{ type: "max", name: "Max" }],
        },
        yAxisIndex: 1,
      },
      {
        name: dataList[2].name,
        type: "line",
        data: dataList[2].data,
        lineStyle: {
          color: dataList[2].color,
        },
        showSymbol: true, //是否默认展示圆点
        symbolSize: 10, //设定实心点的大小
        itemStyle: {
          normal: {
            color: dataList[2].color, //改变折线点的颜色
          },
        },
        markPoint: {
          data: [{ type: "max", name: "Max" }],
        },
        yAxisIndex: 2,
      },
    ],
  };

  return option;
}
